#pragma once
#include <iostream>
#include <pthread.h>

namespace MutexModule
{
 class Mutex
 {
 private:
    pthread_mutex_t _mutex;
    
 public:
    Mutex()
    {
        pthread_mutex_init(&_mutex,nullptr); 
    }
    void Lock()
    {
        pthread_mutex_lock(&_mutex);
    }
    void Unlock()
    {
        pthread_mutex_unlock(&_mutex);
    }
    ~Mutex()
    {
        pthread_mutex_destroy(&_mutex);
    }
   
 };
 class LockGuard
 {
 private:
     Mutex &_mutex;
 public:
     LockGuard(Mutex &mutex):_mutex(mutex)
     {
         _mutex.Lock();
     }
     ~LockGuard()
     {
         _mutex.Unlock();
     }
 };    
}
